using System;
using System.Collections.Generic;
using System.Text;

namespace Instedd.Labs.Forms.Library
{
    public class Survey
    {
        private string id;

        public string ID
        {
            get { return id; }
            set { id = value; }
        }

        private string enteredBy;

        public string EnteredBy
        {
            get { return enteredBy; }
            set { enteredBy = value; }
        }

        private DateTime enteredOn;

        public DateTime EnteredOn
        {
            get { return enteredOn; }
            set { enteredOn = value; }
        }

        private double? latitude;

        public double? Latitude
        {
            get { return latitude; }
            set { latitude = value; }
        }

        private double? longitude;

        public double? Longitude
        {
            get { return longitude; }
            set { longitude = value; }
        }

        private string firstName;

        public string FirstName
        {
            get { return firstName; }
            set { firstName = value; }
        }

        private string lastName;

        public string LastName
        {
            get { return lastName; }
            set { lastName = value; }
        }


        private Address address;

        public Address Address
        {
            get { return address; }
            set { address = value; }
        }

        private string phone;

        public string Phone
        {
            get { return phone; }
            set { phone = value; }
        }

        private string email;

        public string Email
        {
            get { return email; }
            set { email = value; }
        }

        private int totalOccupants;

        public int TotalOccupants
        {
            get { return totalOccupants; }
            set { totalOccupants = value; }
        }

        private int attendedConcert;

        public int AttendedConcert
        {
            get { return attendedConcert; }
            set { attendedConcert = value; }
        }

        private int attendeeContact;

        public int AttendeeContact
        {
            get { return attendeeContact; }
            set { attendeeContact = value; }
        }

        private int symptomsPresent;

        public int SymptomsPresent
        {
            get { return symptomsPresent; }
            set { symptomsPresent = value; }
        }


        private DateTime timeOfOnset;

        public DateTime TimeOfOnset
        {
            get { return timeOfOnset; }
            set { timeOfOnset = value; }
        }

        private int deceased;

        public int Deceased
        {
            get { return deceased; }
            set { deceased = value; }
        }

        private int under9years;

        public int Under9years
        {
            get { return under9years; }
            set { under9years = value; }
        }

        private int pregnant;

        public int Pregnant
        {
            get { return pregnant; }
            set { pregnant = value; }
        }

        private int allergicDoxy;

        public int AllergicDoxy
        {
            get { return allergicDoxy; }
            set { allergicDoxy = value; }
        }

        private int ciproDistributed;

        public int CiproDistributed
        {
            get { return ciproDistributed; }
            set { ciproDistributed = value; }
        }

        private int doxyDistributed;

        public int DoxyDistributed
        {
            get { return doxyDistributed; }
            set { doxyDistributed = value; }
        }

        private string comments;

        public string Comments
        {
            get { return comments; }
            set { comments = value; }
        }

        private int receivedIvTreatment;

        public int ReceivedIvTreatment
        {
            get { return receivedIvTreatment; }
            set { receivedIvTreatment = value; }
        }

        private int recovered;

        public int Recovered
        {
            get { return recovered; }
            set { recovered = value; }
        }

        private string followUpComments;

        public string FollowUpComments
        {
            get { return followUpComments; }
            set { followUpComments = value; }
        }

        private DateTime followUpEnteredOn;

        public DateTime FollowUpEnteredOn
        {
            get { return followUpEnteredOn; }
            set { followUpEnteredOn = value; }
        }

        private int doxyciproAllergy;

        public int DoxyCiproAllergy
        {
            get { return doxyciproAllergy; }
            set { doxyciproAllergy = value; }
        }

        public string AddressDescription
        {
            get { return Address != null ? string.Format("{0}, {2}, {1} ({3})", GetString(Address.StreetAddress), GetString(Address.State), GetString(Address.City), GetString(Address.PostalCode)) : string.Empty; } 
        }

        private string GetString(string s)
        {
            return string.IsNullOrEmpty(s) ? string.Empty : s;
        }

        public int TotalWell { get { return TotalExposed == 0 ? TotalOccupants : 0; } }
        public int TotalExposed { get { return AttendedConcert > 0 || AttendeeContact > 0 || SymptomsPresent > 0 || Deceased > 0 ? TotalOccupants : 0; } }
        public int TotalExposedNotIll { get { return TotalExposed - SymptomsPresent; } }
        public int TotalExposedAndIll { get { return SymptomsPresent; } }
        public int TotalReceivedTreatment { get { return ReceivedIvTreatment; } }
        public int TotalRecovered { get { return Recovered; } }
        public int TotalDeceased { get { return Deceased; } }

        public bool IsBlack { get { return this.TotalDeceased > 0; } }
        public bool IsRed { get { return this.TotalExposedAndIll > 0 && this.ReceivedIvTreatment == 0; } }
        public bool IsPurple { get { return this.TotalExposedAndIll > 0 && this.ReceivedIvTreatment > 0; } }
        public bool IsBlue { get { return this.TotalExposedNotIll > 0 && this.DoxyDistributed == 0 && this.CiproDistributed == 0; } }
        public bool IsPink { get { return this.TotalExposedNotIll > 0 && (this.DoxyDistributed > 0 || this.CiproDistributed > 0); } }
        public bool IsGreen { get { return this.TotalRecovered > 0; } }
        public bool IsWhite { get { return this.TotalWell > 0; } }
    }

    public class Address
    {
        public Address()
        {

        }

        public Address(string street, string city, string state, string postalCode)
        {
            this.streetAddress = street;
            this.city = city;
            this.state = state;
            this.postalCode = postalCode;
        }

        private string streetAddress;

        public string StreetAddress
        {
            get { return streetAddress; }
            set { streetAddress = value; }
        }

        private string city;

        public string City
        {
            get { return city; }
            set { city = value; }
        }

        private string state;

        public string State
        {
            get { return state; }
            set { state = value; }
        }

        private string postalCode;

        public string PostalCode
        {
            get { return postalCode; }
            set { postalCode = value; }
        }
    }

}
